#include <cstring>

#include "console_key_reader.h"
#include "terminal.h"
#include "document.h"
#include "status_message.h"



class Editor{
public: 

    Editor();
    Editor(char*);
    ~Editor();
    
    Document _document;
    static SearchDirection s_direction;

    void run();
    void die();
    bool process_keypress();
    void refresh_screen();
    void draw_rows();
    void draw_status_bar();
    void draw_message_bar();
    void draw_row(Row*);
    void draw_welcome_message();
    void move_cursor(KeyCode);
    void Scroll();
    std::string Prompt(const char* prompt,void (*callback)(Editor* editor,KeyCode key,std::string* str));
    void Save();
    void search();

    static void saveAsCallback(Editor* editor,KeyCode key,std::string* str);
    static void searchCallback(Editor* editor,KeyCode key,std::string* str);

private:
    bool should_quit;
    Terminal _terminal;
    ConsoleKeyReader _reader;
    Position _offset;
    Position _cursor_position;
    StatusMessage* _status_message;
    int _quit_times=0;
    std::string _highlighted_word;


};
